package com.qs.order.controller;

import com.qs.order.dto.OrderDto;
import com.qs.order.message.StreamClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @Desc:  发送端
 * @author: jianfeng
 * @Time: 2019/9/24 9:15
 */
@RestController
public class SendMessageController {

    @Autowired
    private StreamClient streamClient;

//    @GetMapping("/sendMessage")
//    public void process(){
//        String message="now "+new Date();
//        streamClient.output().send(MessageBuilder.withPayload(message).build());
//    }

    /**
    * @Desc:  发送orderDto对象
    * @author: jianfeng
    * @Time: 2019/9/24 9:28
    *
    * @return void
    */
    @GetMapping("/sendMessage")
    public void process(){
        OrderDto orderDto=new OrderDto();
        orderDto.setOrderId("123456");
        streamClient.output().send(MessageBuilder.withPayload(orderDto).build());
    }



}
